package tmproject.hlhj.fhp.anwser.customview

import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.os.Bundle
import kotlinx.android.synthetic.main.anwser_dialog_result.*
import tmproject.hlhj.fhp.anwser.BaseAty
import tmproject.hlhj.fhp.anwser.R
import tmproject.hlhj.fhp.anwser.activitys.AnwserHomeAty
import tmproject.hlhj.fhp.anwser.activitys.WebAty

/**
 * Created by Never Fear   on 2018\8\24 0024.
Never More....
 */
class ResultDialog(private val c:Context,private val bundle: Bundle):Dialog(c, R.style.MyDialog) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.anwser_dialog_result)
        when (bundle.getInt("type",-1)){
            1->{
                img.setImageResource(R.drawable.ic_dt_jiangbei)
                tv1.text="闯关成功"
                tv2.text="共计答题 ${bundle.getInt("num")} 道             累计分数：${bundle.getInt("point")} 分"
                tv3.text="恭喜获得 ${bundle.getInt("chance")} 次抽奖机会"
                btYes.text="立即抽奖"
                btYes.setOnClickListener {
                    val intent = Intent(c,WebAty::class.java)
                    intent.putExtra("type",1)
                    c.startActivity(intent)
                }
            }
            2->{
                img.setImageResource(R.drawable.ic_dt_jiangbei)
                tv1.text="闯关失败"
                tv2.text="共计答题 ${bundle.getInt("num")} 道             累计分数：${bundle.getInt("point")} 分"
                tv3.text="闯关未成功，请下次再试"
                btYes.text="下次再来"
                btYes.setOnClickListener {
                    dismiss()
                }

            }
        }


        btExit.setOnClickListener {
            dismiss()
        }
    }

    override fun dismiss() {
        if (c is AnwserHomeAty){
            c.refresh()
        }
        super.dismiss()
    }
}